import string
from random import choice
import time


def generate_random(random_length, type):
    """
    随机字符串生成函数
    :param random_length:字符串长度
    :param type:字符串类型（0：纯数字 or 1：数字+字符 or 2：数字+字符+特殊字符）
    :return:生成的随机字符串
    """
    # 随机字符串种子
    if type == 0:
        random_seed = string.digits
    elif type == 1:
        random_seed = string.digits + string.ascii_letters
    elif type == 2:
        random_seed = string.digits + string.ascii_letters + string.punctuation
    random_str = []
    while len(random_str) < random_length:
        random_str.append(choice(random_seed))
    return ''.join(random_str)


def my_goods_id():
    rand = generate_random(6, 0)
    my_id = 'C' + rand
    return my_id


def my_pcb_id():
    rand = generate_random(6, 0)
    my_id = 'P' + rand
    return my_id


def my_weld_id():
    times = time.strftime('%y%m%d', time.localtime(time.time()))
    rand = generate_random(2, 0)
    my_id = 'P' + times + rand
    return my_id


def my_putin_id():
    times = time.strftime('%y%m%d', time.localtime(time.time()))
    rand = generate_random(2, 0)
    my_id = 'S' + times + rand
    return my_id


if __name__ == "__main__":
    # print(generate_random(6, 0))
    id = my_pcb_id()
    print(id)
